import Koa from 'koa'
const app = new Koa()
import routing from './routes/index'
import koaJsonError from 'koa-json-error'
import koaBody from 'koa-body'
import response from './middleware/response'

app.use(koaJsonError())
app.use(
  koaBody({
    multipart: true,
    formidable: {
      keepExtensions: true,
      maxFieldsSize: 1 * 1024 * 1024
    }
  })
)

app.use(response()) // 规定返回值的格式
// 路由
routing(app)

app.listen(3000, () => {
  console.log('发票服务运行在3000端口')
})
